package com.game.centerserver.infrastructure.service.impl;

import com.game.centerserver.infrastructure.entity.DstClusterToken;
import com.game.centerserver.infrastructure.dao.DstClusterTokenDao;
import com.game.centerserver.infrastructure.service.DstClusterTokenService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (DstClusterToken)表服务实现类
 *
 * @author makejava
 * @since 2024-11-11 22:20:11
 */
@Service("dstClusterTokenService")
public class DstClusterTokenServiceImpl implements DstClusterTokenService {
    @Resource
    private DstClusterTokenDao dstClusterTokenDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public DstClusterToken queryById(Integer id) {
        return this.dstClusterTokenDao.queryById(id);
    }

    @Override
    public DstClusterToken queryByArchiveId(String archiveId) {
        return dstClusterTokenDao.queryByArchiveId(archiveId);
    }

    @Override
    public List<DstClusterToken> queryAll() {
        return dstClusterTokenDao.queryAll();
    }

    /**
     * 新增数据
     *
     * @param dstClusterToken 实例对象
     * @return 实例对象
     */
    @Override
    public boolean insert(DstClusterToken dstClusterToken) {
        DstClusterToken dstClusterToken1 = dstClusterTokenDao.queryByArchiveId(dstClusterToken.getArchiveId());
        if (dstClusterToken1 != null){
            return false;
        }
        return this.dstClusterTokenDao.insert(dstClusterToken) > 0;
    }

    /**
     * 修改数据
     *
     * @param dstClusterToken 实例对象
     * @return 实例对象
     */
    @Override
    public boolean update(DstClusterToken dstClusterToken) {
        return this.dstClusterTokenDao.update(dstClusterToken) > 0;
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.dstClusterTokenDao.deleteById(id) > 0;
    }

    @Override
    public boolean deleteByArchiveID(String archiveId) {
        return dstClusterTokenDao.deleteByArchiveId(archiveId) > 0;
    }
}
